##Correspondence Analysis library(vegan) speabu<-read.csv('abund.csv', header=T, row.names=1) #transform to presence absence (binary) speocc<-data.trans(speabu[,-1], method='power', exp=0, plot=F) #perform CA spe.ca<-cca(speocc) #results are complex and sotred in a list that gives eigenvalues (intertia), and eigenvectors(sample and species scores) summary(spe.ca) #use a randomization test to look at statistical significance of the first several eigenvalues ordi.monte(speocc[,-1],ord='ca', dim=5, perm=500) # we can also look at this info graphically ordi.scree(spe.ca,ord='ca') #to look at the sample and species scores.. ('u' is sample scores, 'v' is species scores) spe.ca$CA$u[,1:2] spe.ca$CA$v[,1:2] #or look at scaled scores spe.ca$CA$u.eig[,1:2] spe.ca$CA$v.eig[,1:2] #in CA choice of scaling type is important either the ordination of rows (samples) or columns (species) is meaningful and can be interpreted as an approximation of the chi-square distances between samples or species, respectively #in scaling type 1: sample scores are calculated as weighted averages of species scores, in scaling type 2: species scores are calculated as weighted averages of sample scores, scaling type 3: sample and species scores are scaled symmetrically (both by the square root of the eigenvalues) #create a CA joint plot ordiplot(spe.ca, choices=c(1,2), scaling=2) #or a labelier one ordiplot(spe.ca, type='n', scaling=2) text(spe.ca$CA$v.eig[,1:2],labels=row.names(spe.ca$CA$v.eig), cex=0.7) text(spe.ca$CA$u[,1:2], labels=row.names(spe.ca$CA$u), cex=0.7, col='red') #DETRENDING - we didn't really like this in class so I'll write it out but probably won't use it. Seems fakey and manipulative (but done to get rid of horseshoe effect) spe.dca<-decorana(speocc,ira=0) spe.dca summary(spe.dca) plot(spe.dca) #going to try this with my catagorical data exonFC<-read.csv('exonsforconting.csv', header=TRUE, row.names=1) summary(exonFC) exon.ca<-cca(exonFC) #ok, doesn't work, says it needs to be numeric. I thought it worked off a contingency table.